require '/Users/drewwhitehurst/views/ruby/VisioToCode/XMLFileStringManager.rb'

class Tags
	attr_accessor :rawString
	attr_accessor :tagName
	attr_accessor :tagAttributes
  attr_accessor :tagContent
  attr_accessor :tagChildElements

	def initialize(xmlStringManager)

    @xmlString = xmlStringManager

    # do we need to process anything
    if(@xmlString.isNextTagHead)

      # get temp string
      tempHead = @xmlString.getTagAttributes

      # get tag name
      @tagName = filterTagName(tempHead)

      # get attributes if they exist
      @tagAttributes = filterTagAttributes(tempHead)

      # is this only attributes
      if isTagAttributeOnly(tempHead) 
        # this is done excuting
      
      # done with recursive calls
      elsif @xmlString.isNextTagTail
        # done executing
        # let system exit

      # recursive call if child element found
      elsif @xmlString.isNextTagHead
        # add new object to tagChildElements
        # will return here when recursive action is doen
      end

      puts isTagAttributeOnly(tempHead)
    end

    if(@xmlString.isNextTagTail)
      tempTail = @xmlString.getTagTail
    end

	end

  def filterTagTail(tagString)
    openTag = tagString.index "<"
    closeTag = tagString.index "/>"

    return tagString[(openTag + 1),(closeTag - 1)]
  end

  def filterTagName(tagString)
    beginSlice = tagString.index "<"
    finalSlice = tagString.index " "

    # filter tag with no attributes
    if(nil == finalSlice)
      finalSlice = tagString.index ">"
    end

    return tagString[(beginSlice + 1),finalSlice]
  end

  def filterTagAttributes(tagString)
    beginSlice = tagString.index " "
    finalSlice = tagString.index ">"

    return removeCloseTag(tagString[(beginSlice + 1),finalSlice])
  end

  def removeCloseTag(tagString)

    return tagString.delete ">"
  end

  def isTagAttributeOnly(tagString)
    
    return tagString.index "/>"
  end

end



temp = XMLFileStringManager.new
temp.removeXMLHeader

visioTags = Tags.new(temp)


puts("\nfin")
